package com.coin900.coin.service.sop;

import com.coin900.coin.persist.sop.SopUserVO;
import com.value.mybatis.IDaoRouter;
import com.value.mybatis.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author shui
 * @create 2018-01-06
 **/
@Service
public class SopUserService implements ISopUserService {

    @Override
    public List<SopUserVO> loadSopUser(Map<String, Object> params) {
        return this.daoRouter.query("SopUser.loadSopUser", params);
    }

    @Override
    public List<SopUserVO> loadSopUserForPage(Pagination pagination) {
        return this.daoRouter.query("SopUser.loadSopUserForPage", pagination);
    }

    @Override
    public void insertSopUser(SopUserVO sopUserVO) {
        // 用户状态可用
        sopUserVO.setUserStatus(1);
        // 邮箱状态未验证
        sopUserVO.setEmailStatus(0);
        // 手机状态未验证
        sopUserVO.setMoblieStatus(0);
        this.daoRouter.insert("SopUser.insertSopUser", sopUserVO);
    }

    @Override
    public void doResetSopUser(SopUserVO sopUserVO) {
        // 重置默认密码 123456
        sopUserVO.setPassword("123456");
        this.updateSopUser(sopUserVO);
    }

    @Override
    public void updateSopUser(SopUserVO sopUserVO) {
        this.daoRouter.update("SopUser.updateSopUser", sopUserVO);
    }

    @Override
    public void deleteSopUser(SopUserVO sopUserVO) {
        this.daoRouter.update("SopUser.deleteSopUser", sopUserVO);
    }

    @Autowired
    private IDaoRouter daoRouter;

}